package com.hdey.controller.max;

import com.hdey.pojo.max.TbUscStock;
import com.hdey.service.max.TbUscStockSvs;
import com.hdey.utils.Result;
import com.hdey.vo.StockVo;
import com.hdey.vo.StockVoForSearch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/stock")
@Slf4j
public class TbUscStockController {


    @Resource
    private TbUscStockSvs stockSvs;

    private String msg;

    @RequestMapping("/getStock")
    public Result getDictionary(StockVoForSearch stock){
        //System.out.println(stock.toString());

        List<StockVo> list = stockSvs.getStock(stock);
        return Result.success(list,list.size());
    }


    @RequestMapping("/updateStockAmount")
    public Result updateStockAmount(TbUscStock stock){
        int result = stockSvs.updateStockAmount(stock);
        if(result > 0){
            msg = "库存已修正！";
        }else{
            msg = "系统错误！";
        }

        return Result.success(msg);
    }



}
